//
//  FP_UserPriceInquiryInfoCell.m
//  FootPad
//
//  Created by 张浩 on 2022/2/17.
//  Copyright © 2022 胶享悦. All rights reserved.
//

#import "MM_HomeSearchRightCell.h"

static const CGFloat addTitleTag = 2000;

@interface MM_HomeSearchRightCell ()

@property (nonatomic, strong) UIView *baseView;

@end

@implementation MM_HomeSearchRightCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [ColorUtil colorWithHexadecimal:@"#ffffff"];
        [self.contentView addSubview:_baseView];
        
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.right.top.bottom.equalTo(self.contentView);
            make.height.equalTo(50);
        }];
        
    }
    return self;
}

- (void)setModel:(MM_HomeSearchRightModel *)model {
    _model = model;
    
    NSArray *titleArr = @[!stringIsEmpty(model.location_name)?model.location_name:@"",!stringIsEmpty(model.shelf_number)?model.shelf_number:@"",!stringIsEmpty(model.layer_number)?model.layer_number:@"",!stringIsEmpty(model.tag_number)?model.tag_number:@""];
    CGFloat titleW = (ScreenW - 180)/4.0;
        
    for (UIView*subView in self.baseView.subviews) {
        
        [subView removeFromSuperview];
    }
    
    for (int i=0; i<titleArr.count; i++) {
        
        UIView *titleView = [[UIView alloc] init];
        titleView.backgroundColor = [ColorUtil colorWithHexadecimal:@"#ffffff"];
        titleView.tag = addTitleTag + i;
        [self.baseView addSubview:titleView];
        
        [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.equalTo(titleW *i);
            make.top.height.equalTo(self.baseView);
            make.width.equalTo(titleW);
        }];
                
        UILabel *nameLabel = [Custom_ZHTool uiLabelCreate:titleArr[i] Font:FONT(14) TextColor:[ColorUtil colorWithHexadecimal:@"#333333"]];
        nameLabel.numberOfLines = 0;
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.textColor = [ColorUtil colorWithHexadecimal:@"#333333"];
        
        if (i == 6) {
            
            nameLabel.textColor = MM_ColorUtil(@"#DE1212");
        }
        
        [titleView addSubview:nameLabel];
        
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerX.centerY.equalTo(titleView);
        }];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
